package cn.piesat.controller;

import cn.piesat.util.ResponseWrapperUtil;
import cn.piesat.util.queue.RequestQueue;
import cn.piesat.vo.AsyncVo;
import cn.piesat.vo.RecordVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;

/**
 * @author zyp
 * @date 2021/3/15
 */
@RestController
@RequestMapping("/log")
public class LoggerController {
    @Autowired
    private RequestQueue queue;

    @PostMapping("/add")
    public String add(@RequestBody RecordVo recordVo) throws InterruptedException {
        AsyncVo<String, Object> vo = new AsyncVo<>();
        DeferredResult<Object> result = new DeferredResult<>();
        vo.setParams(recordVo);
        vo.setResult(result);
        queue.getOrderQueue().put(vo);
        return ResponseWrapperUtil.executeCustomTips("true","添加成功");
    }
    @GetMapping("/test")
    public String test( String str){
        return ResponseWrapperUtil.executeCustomTips("true","添加成功");
    }
}
